<!DOCTYPE html>
<html lang="zh-Hans-CN">
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="../vue.js"></script>
</head>
<body>
<h2>【例30】组件切换 v-if v-else</h2>
<hr>
<div id="app">
    <a href="#" @click.prevent="flag ? flag : flag = !flag">登录</a>
    <a href="#" @click.prevent="flag ? flag = !flag : flag">注册</a>
    <a @click.prevent="flag ? flag = !flag : flag">注册00</a>
    <a href="http://www.baidu.com" target="_blank" @click.prevent="flag ? flag = !flag : flag">注册11</a>
    <a href="http://www.baidu.com" target="_blank" @click="flag ? flag = !flag : flag">注册22</a>
    <div style="height: 500px">
        <login v-if="flag"></login>
        <register v-else="flag"></register>
    </div>
</div>
<script>
    Vue.component('login', {
        template: '<div><h2>用户登录界面</h2>登录</div>'
    });
    Vue.component('register', {
        template: '<div><h2>用户注册界面</h2>注册</div>'
    });
    let vm = new Vue({
        el: '#app',
        data: {flag: true}
    })
</script>
<hr>
<p><a href="index.html">返回章节目录</a>
    <script>document.write(document.lastModified); </script>
</p>
</body>
</html>
